package com.ts.api.module.match.plan.model;

import com.ts.api.common.constant.product.ProductPlanTypeEnum;
import com.ts.api.module.channel.entity.po.ChannelPO;
import com.ts.api.module.channel.entity.po.ChannelUserFormFieldPO;
import com.ts.api.module.channel.entity.po.ChannelUserRegisterPO;
import com.ts.api.module.match.plan.internal.core.PlanMatchChannelType;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.util.List;

/**
 *  自有渠道匹配实体
 *
 *  @author Pan
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class ChannelPlanMatch extends AbstractPlanMatch {

    /** 渠道信息 */
    private ChannelPO channelPO;
    /** 用户信息 */
    private ChannelUserRegisterPO channelUserRegisterPO;
    /** 用户表单 */
    private List<ChannelUserFormFieldPO> listUserForm;

    public ChannelPlanMatch() {
        super();
    }

    /**
     *  构建匹配实体
     *
     *  @param  channelPO               自有渠道实体
     *  @param  channelUserRegisterPO   用户注册信息
     *  @param  listUserForm            表单信息
     *  @param  listPlanType            匹配计划类型
     *  @return ApiPlanMatch
     */
    public static ChannelPlanMatch ofMatch(ChannelPO channelPO, ChannelUserRegisterPO channelUserRegisterPO, List<ChannelUserFormFieldPO> listUserForm,
                                                                                                             List<ProductPlanTypeEnum> listPlanType) {

        ChannelPlanMatch channelPlanMatch = new ChannelPlanMatch();
        channelPlanMatch.setChannelPO(channelPO);
        channelPlanMatch.setLoanChannelId(channelPO.getId());
        channelPlanMatch.setChannelUserRegisterPO(channelUserRegisterPO);
        channelPlanMatch.setListUserForm(listUserForm);
        channelPlanMatch.setPlanMatchChannelType(PlanMatchChannelType.CHANNEL);
        channelPlanMatch.setListPlanType(listPlanType);
        channelPlanMatch.setHttpTimeout(5000);
        channelPlanMatch.setChannelPrice(channelPO.getPrice());
        channelPlanMatch.setChannelShareRatio(new BigDecimal("0.00"));
        return channelPlanMatch;
    }

}
